<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>碧选跳转</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html,
        body {
            position: relative;
            width: 100%;
            height: 100%;
        }

        .open-app {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }

        .error {
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, .1);
            text-align: center;
            display: none;
        }

        .pendding {
            display: inline-block;
            width: 200px;
            padding: 10px 20px;
            color: #fff;
            border-radius: 4px;
            background: palevioletred;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="open-app">
        <a class="pendding">点击进入碧选App</a>
    </div>
    <div class="error">
        <img class="" src='./images/arrow.png'>
    </div>
    <script src="https://unpkg.com/callapp-lib@2.1.5/dist/index.umd.min.js"></script>
    <script src='./utils.js'></script>
    <script>
        function isWeiXin() {
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                return true;
            } else {
                return false;
            }
        }
        window.onload = function () {
            var $el = document.querySelector('.error')
            var $el2 = document.querySelector('.pendding')
            if (isWeiXin()) {

                $el.style.display = 'block'
                $el2.style.display = 'none'
            } else {
                $el2.addEventListener('click', function () {
                    // alert("dianji")
                    var id = Utils.getParam('id') || ''
                    var anchorId = Utils.getParam('anchorId') || ''
                    var invitationCode = Utils.getParam('invitationCode') || ''
                    var option = {
                        scheme: {
                            protocol: 'bixuan',
                        },
                        intent: {
                            package: 'com.bisinuolan.app',
                            scheme: 'bixuan',
                        },
                        appstore: 'https://itunes.apple.com/cn/app/id1243270000',
                        yingyongbao: 'https://android.myapp.com/myapp/detail.htm?apkName=com.bisinuolan.app&ADTAG=mobile',
                        fallback: 'https://android.myapp.com/myapp/detail.htm?apkName=com.bisinuolan.app&ADTAG=mobile',
                        timeout: 3000,
                    };
                    var lib = new CallApp(option);
                    var callButton = document.querySelector('#call-button');
                    lib.open({
                        param: {
                            type: 'zb',
                            id: id || '',
                            invitationCode: invitationCode || '',
                            anchorId: anchorId || ''
                        }
                    });
                })
            }
        }
    </script>
</body>

</html>